package com.smy.jkds.controller;

import com.smy.jkds.po.Card;
import com.smy.jkds.po.TTaskRecord;
import com.smy.jkds.service.CardService;
import com.smy.jkds.service.TTaskRecordService;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * @author z01140
 * @Package: com.smy.jkds.controller
 * @Description:
 * @CreateDate 2021/10/30 11:31
 * @UpdateDate 2021/10/30 11:31
 */
@RestController
public class HeakthCheckController {


    @GetMapping("/jkds/health")
    public String health(){
        return "ok";
    }

    @Autowired
    TTaskRecordService tTaskRecordService;
    @Autowired
    CardService cardService;

    @GetMapping("/jkds/test")
    public void test(){
        Random r = new Random();
        TTaskRecord record = new TTaskRecord();
        record.setUserId("abcde");
        record.setUserName("zm");
        for (int i = 0; i < 10000; i++) {
            record.setTitle(RandomStringUtils.randomAscii(10));
            Integer circle = r.nextInt(10);
            record.setCircle(circle);
            tTaskRecordService.save(record);
            for (int j = 0; j < circle; j++) {
                Card card = new Card();
                card.setTaskId(record.getId());
                card.setUserId(record.getUserId());
                card.setUserName(record.getUserName());
                card.setContent(RandomStringUtils.randomAscii(20));
                cardService.save(card);
            }
        }
    }
}
